package me.liuyu.ymall.member.oauth.api;

import me.liuyu.ymall.common.YmHttpResponse;
import me.liuyu.ymall.member.oauth.DO.MemberInfo;
import me.liuyu.ymall.member.oauth.service.MemberInfoService;
import me.liuyu.ymall.member.point.client.MemberPointClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author liuyu E-mail: liuyu2783@163.com
 * @Date 2018/5/25 11:20
 * @Descrption
 * @Modified By
 */
@RestController
@RequestMapping
public class MemberApi {

    private Logger logger = LoggerFactory.getLogger(MemberApi.class);
    @Autowired
    private MemberInfoService memberService;
    @Autowired
    private MemberPointClient memberPointClient;


    @RequestMapping("getMemberInfo")
    public MemberInfo getMemberInfo(@RequestParam("id") Long id){
        logger.info("查询会员，id={}", id);
        return memberService.selectById(id);
    }

    @RequestMapping("insertMember")
    public YmHttpResponse insertMember(@RequestBody MemberInfo memberInfo){
        logger.info("新增会员，{}", memberInfo);
        memberService.insert(memberInfo);
        return YmHttpResponse.success();
    }

    @RequestMapping("listMyPointHis")
    public YmHttpResponse listMyPointHis(@RequestParam("id") Long id){
        logger.info("查询我的积分列表，id={}",id);
        List list = memberPointClient.listMyPointHis(id);
        logger.info("查询我的积分列表，结果 {}", list);
        return YmHttpResponse.success(list);
    }

}
